<template>
  <view class="content_page">
    <SettingStatus v-if="currentTab == 0" :equipmentId="equipmentId" :lat="lat" :lng="lng" ></SettingStatus>
    <SettingPlan v-if="currentTab == 1" :equipmentId="equipmentId" :workType="workType" :currentSprayModal="currentSprayModal"></SettingPlan>
    <SettingSenior v-if="currentTab == 2" :equipmentId="equipmentId" 
     :workType="workType" :categoryName="categoryName"></SettingSenior>
    <!-- 导航栏 -->
    <view>
      <up-tabbar @change="changePage" :fixed="true" :placeholder="false" :safeAreaInsetBottom="false" activeColor="#333"
        inactiveColor="#939393" :value="currentTab">
        <up-tabbar-item text="状态">
          <template #active-icon>
            <image class="u-page__item__slot-icon" src="/static/home/teb_shebei@2x.png"></image>
          </template>
          <template #inactive-icon>
            <image class="u-page__item__slot-icon" src="/static/home/device_state_sel@2x.png"></image>
          </template>
        </up-tabbar-item>
        <up-tabbar-item text="计划">
          <template #active-icon>
            <image class="u-page__item__slot-icon" src="/static/home/device_calendar.png"></image>
          </template>
          <template #inactive-icon>
            <image class="u-page__item__slot-icon" src="/static/home/device_calendar_sel.png"></image>
          </template>
        </up-tabbar-item>
        <up-tabbar-item text="高级">
          <template #active-icon>
            <image class="u-page__item__slot-icon" src="/static/home/device_senior.png"></image>
          </template>
          <template #inactive-icon>
            <image class="u-page__item__slot-icon" src="/static/home/device_senior_sel.png"></image>
          </template>
        </up-tabbar-item>
      </up-tabbar>
    </view>
  </view>
</template>
<script setup lang="ts">
import { ref, getCurrentInstance } from "vue";
import { onLoad, onUnload } from "@dcloudio/uni-app";
import SettingStatus from "@/components/SettingStatus.vue";
import SettingPlan from "@/components/SettingPlan.vue";
import SettingSenior from "@/components/SettingSenior.vue";
const currentTab = ref(0)
const currentSprayModal = ref()
const changePage = (newTabIndex: any) => {
  currentTab.value = newTabIndex
};
const equipmentId = ref<string>("");
const workType = ref<string>("");
const cleanTime = ref<string>("");
const waterPressure = ref<string>("");
const coolStatus = ref<boolean>(false);
const categoryName = ref('')
const lat = ref('')
const lng = ref('')
  const instance = getCurrentInstance();
const appStorage = instance?.appContext.config.globalProperties.appStorage;
onLoad((options) => {
  if (options?.currentTab) {
    currentTab.value = options.currentTab;  
    currentSprayModal.value = options.currentSprayModal
    console.log(currentSprayModal.value,'xxxxxx');
  }
  const storedTabInfo = appStorage.getObj("device_info");
    if (storedTabInfo) {
      equipmentId.value = storedTabInfo?.equipmentId;
      workType.value = storedTabInfo?.workType;
      cleanTime.value = storedTabInfo?.cleanTime;
      waterPressure.value = storedTabInfo?.waterPressure;
      coolStatus.value = storedTabInfo?.coolStatus;
      lat.value = storedTabInfo?.lat;
      lng.value = storedTabInfo?.lng;
      categoryName.value = storedTabInfo?.categoryName;
    }
});
onUnload(() => {
  currentTab.value = 0
});
</script>

<style scoped lang="scss">
</style>
